package com.lynn.springboot_demo.quartz;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author cl
 * @Date 2020/9/23 10:45
 * 定时任务配置
 */
@Configuration
public class QuartzConfid {
    //任务2的描述
    @Bean
    public JobDetail testQuartz02() {
        return JobBuilder.newJob(TestTask2.class).withIdentity("testTask2").storeDurably().build();
    }

    //任务2的触发器
    @Bean
    public Trigger testQuartz02Trigger() {
        //corn的方式，每50秒执行一次
        return TriggerBuilder.newTrigger().forJob(testQuartz02())
                .withIdentity("testTask2")
                .withSchedule(CronScheduleBuilder.cronSchedule("*/30 * * * * ?"))
                .build();
    }
}

